# Contributor: Leon ROUX <leon.roux@federate.us>
# Maintainer: Leon ROUX <leon.roux@federate.us>
pkgname=aptdec
pkgver=1.8.0
pkgrel=0
pkgdesc="NOAA APT satellite imagery decoder library"
_argparse=c612dc03958cdbd538ca306d61853b643a435933
url="https://github.com/Xerbo/aptdec"
license="GPL-2.0-or-later"
arch="all"
makedepends="
	cmake
	libpng-dev
	libsndfile-dev
	samurai
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/Xerbo/aptdec/archive/refs/tags/v$pkgver.tar.gz
	argparse-$_argparse.tar.gz::https://github.com/cofyc/argparse/archive/$_argparse.tar.gz
	soname-dynlink.patch
	"
options="!check" # does not have any tests

prepare() {
	default_prepare

	rmdir src/argparse
	ln -sfv "$srcdir"/argparse-$_argparse \
		"$builddir"/src/argparse
}

build() {
	CFLAGS="$CFLAGS -O2 -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O2 -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_SKIP_RPATH=ON \
		-DVERSION="$pkgver"
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
3d10aa33bc443ba0ce00be7d00a5c95de54f98d13818a84535971a35575e1012a9c579cf154e17ffb3fe3d03fa964d11f7589082c9b4cab53c5b4ff1efc84c96  aptdec-1.8.0.tar.gz
77370375e7594a640d410f051ed6230b2f81e47dea88498cefdd9285e28b620c4e096fab24bf4067b755343be3b7d0f71bc361e8ad00ac047c1b9d53890647d0  argparse-c612dc03958cdbd538ca306d61853b643a435933.tar.gz
264070fa0759cd070753f22702a3466cf72f4d1fda85a15fa905774654c456a04e9e75eedd7b4ee5add3124d65230f0fc86f07880e65770a1eef3341068a3a66  soname-dynlink.patch
"
